package net.lanelife.casino.caipiao.entity.support;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;

import net.lanelife.casino.caipiao.entity.User;
import net.lanelife.casino.common.entity.annotation.Checked;
import net.lanelife.casino.common.entity.support.CheckableEntity;

@MappedSuperclass
public abstract class UserRelationEntity<PK extends Serializable> extends CheckableEntity<PK> {

	private static final long serialVersionUID = 7405522757503732970L;

	/**
	 * 用户ID
	 */
	@Checked
	@Column(name = "USER_ID", nullable = false)
	private Integer userId;
	
	/**
	 * 用户帐号
	 */
	@Checked
	@Column(name = "USER_NAME", length = 16, nullable = false)
	private String userName;
	
	/**
	 * 上级ID
	 */
	@Checked
	@Column(name = "PARENT_ID")
	private Integer parentId;

	/**
	 * 上级帐号
	 */
	@Checked
	@Column(name = "PARENT_NAME", length = 16)
	private String parentName;

	/**
	 * 层级
	 */
	@Checked
	@Column(name = "FLOOR", nullable = false)
	private Integer floor;

	/**
	 * 路径
	 */
	@Checked
	@Column(name = "PATH", length = 200, nullable = false)
	private String path;
	
	public UserRelationEntity() {}
	
	public UserRelationEntity(User user) {
		this.userId = user.getId();
		this.userName = user.getUserName();
		this.parentId = user.getParentId();
		this.parentName = user.getParentName();
		this.floor = user.getFloor();
		this.path = user.getPath();
	}

	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public Integer getParentId() {
		return parentId;
	}

	public void setParentId(Integer parentId) {
		this.parentId = parentId;
	}

	public String getParentName() {
		return parentName;
	}

	public void setParentName(String parentName) {
		this.parentName = parentName;
	}

	public Integer getFloor() {
		return floor;
	}

	public void setFloor(Integer floor) {
		this.floor = floor;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}
	
	public User getUser() {
		User user = new User();
		user.setId(this.getUserId());
		user.setUserName(this.getUserName());
		user.setParentId(this.getParentId());
		user.setParentName(this.getParentName());
		user.setFloor(this.getFloor());
		user.setPath(this.getPath());
		return user;
	}
	
	
	
}
